package xw.qxypt.modules.baseinfo.service.impl;

import org.apache.commons.lang.StringUtils;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import xw.qxypt.common.utils.PageUtils;
import xw.qxypt.common.utils.Query;

import xw.qxypt.modules.baseinfo.dao.LhpRfpLogDao;
import xw.qxypt.modules.baseinfo.entity.LhpRfpLogEntity;
import xw.qxypt.modules.baseinfo.service.LhpRfpLogService;


@Service("lhpRfpLogService")
public class LhpRfpLogServiceImpl extends ServiceImpl<LhpRfpLogDao, LhpRfpLogEntity> implements LhpRfpLogService {

    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        IPage<LhpRfpLogEntity> page = this.page(
                new Query<LhpRfpLogEntity>().getPage(params),
                new QueryWrapper<LhpRfpLogEntity>()
        );

        return new PageUtils(page);
    }

    @Override
    public List<LhpRfpLogEntity> getByPointCode(String pointCode) {
       pointCode = "AB" + pointCode.substring(2);
       List<LhpRfpLogEntity> logList=this.list(
               new QueryWrapper<LhpRfpLogEntity>()
                       .eq(StringUtils.isNotBlank(pointCode),"point_code", pointCode)
                       .orderByDesc("log_time")
       );
       return logList;
    }

}
